using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B.S.Domain.Dto.ShenchanDto
{
    /// <summary>
    /// 生产信息DTO
    /// </summary>
    public class ShenchanInfoDTO
    {
        /// <summary>
        /// 时间戳+从1开始的序列号
        /// </summary>
        public string SID { get; set; } = string.Empty;

        /// <summary>
        /// 产品物料ID（外键）
        /// </summary>
        public int Productid { get; set; }

        /// <summary>
        /// 工艺路线ID（外键）
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 产品名称
        /// </summary>
        public string ProductName { get; set; } = string.Empty;

        /// <summary>
        /// 规格
        /// </summary>
        public string ProductStandard { get; set; } = string.Empty;

        /// <summary>
        /// 产品数量
        /// </summary>
        public int ProductCount { get; set; }

        /// <summary>
        /// 产品颜色
        /// </summary>
        public string ProductColor { get; set; } = string.Empty;
    }

    /// <summary>
    /// 生产信息详细DTO（包含关联信息）
    /// </summary>
    public class ShenchanInfoDetailDTO : ShenchanInfoDTO
    {
        /// <summary>
        /// 产品物料信息
        /// </summary>
        public ProductMaterialInfo? ProductMaterial { get; set; }

        /// <summary>
        /// 工序路线信息
        /// </summary>
        public ProcessrouteInfo? Processroute { get; set; }
    }

    /// <summary>
    /// 产品物料信息
    /// </summary>
    public class ProductMaterialInfo
    {
        public int Productid { get; set; }
        public string Productcode { get; set; } = string.Empty;
        public string ProductName { get; set; } = string.Empty;
        public string Specifications { get; set; } = string.Empty;
        public string Unit { get; set; } = string.Empty;
        public decimal Earlywarningvalue { get; set; }
        public string Describe { get; set; } = string.Empty;
    }

    /// <summary>
    /// 工序路线信息
    /// </summary>
    public class ProcessrouteInfo
    {
        public int Id { get; set; }
        public string ProcessrouteName { get; set; } = string.Empty;
        public string? Image { get; set; }
        public string ProcessrouteType { get; set; } = string.Empty;
        public bool ProcessrouteState { get; set; }
        public string? ProcessrouteDescription { get; set; }
        public string ProcessrouteCreatorName { get; set; } = string.Empty;
        public DateTime ProcessrouteCreatorTime { get; set; }
    }

    /// <summary>
    /// 生产信息创建DTO
    /// </summary>
    public class ShenchanInfoCreateDTO
    {
        /// <summary>
        /// 产品物料ID（外键）
        /// </summary>
        [Required(ErrorMessage = "产品物料ID不能为空")]
        public int Productid { get; set; }

        /// <summary>
        /// 工艺路线ID（外键）
        /// </summary>
        [Required(ErrorMessage = "工艺路线ID不能为空")]
        public int Id { get; set; }

        /// <summary>
        /// 产品名称
        /// </summary>
        [Required(ErrorMessage = "产品名称不能为空")]
        [StringLength(100, ErrorMessage = "产品名称长度不能超过100个字符")]
        public string ProductName { get; set; } = string.Empty;

        /// <summary>
        /// 规格
        /// </summary>
        [Required(ErrorMessage = "产品规格不能为空")]
        [StringLength(100, ErrorMessage = "产品规格长度不能超过100个字符")]
        public string ProductStandard { get; set; } = string.Empty;

        /// <summary>
        /// 产品数量
        /// </summary>
        [Required(ErrorMessage = "产品数量不能为空")]
        [Range(1, int.MaxValue, ErrorMessage = "产品数量必须大于0")]
        public int ProductCount { get; set; }

        /// <summary>
        /// 产品颜色
        /// </summary>
        [StringLength(50, ErrorMessage = "产品颜色长度不能超过50个字符")]
        public string ProductColor { get; set; } = string.Empty;
    }

    /// <summary>
    /// 生产信息更新DTO
    /// </summary>
    public class ShenchanInfoUpdateDTO : ShenchanInfoCreateDTO
    {
        /// <summary>
        /// 生产信息ID
        /// </summary>
        [Required(ErrorMessage = "生产信息ID不能为空")]
        public string SID { get; set; } = string.Empty;
    }

    /// <summary>
    /// 生产信息查询DTO
    /// </summary>
    public class ShenchanInfoQueryDTO
    {
        /// <summary>
        /// 页码
        /// </summary>
        public int PageIndex { get; set; } = 1;

        /// <summary>
        /// 页大小
        /// </summary>
        public int PageSize { get; set; } = 20;
    }
}
